package com.fbty.mt.action.user;

import java.util.List;
import java.util.Map;

import com.fbty.base.action.BaseAction;
import com.fbty.base.domain.Page;
import com.fbty.mt.domain.User;
import com.fbty.mt.service.OtherService;
import com.fbty.mt.service.UserIpInfoService;

public class UserIpAction  extends BaseAction{

	private UserIpInfoService userIpInfoService;

	private Page sharePage;
	
	private Page onlyPage;
	
	private String state="%%";
	
	private int shareNo=1;
	
	private int pageSize=10;
	
	private int onlyNo=1;
	private int onlySize=5;
	
	private Map<String,Object> map;
	
	private List<String> shareCountries;
	private List<String> shareTypes;
	private List<String> countries;
	private List<String> types;
	private OtherService otherService;
	private String sharetype="";
	
	private String sharecountry="";
	
	private String shareregion="";
	
	private String sharecity="";
	private String type="";
	
	private String country="";
	
	private String region="";
	
	private String city="";
	
	public String execute(){
		User u = (User)sessionMap.get("user");
		if(u==null){
			return "login";
		}
		String nsharetype= "".equals(sharetype)?"%"+sharetype+"%":sharetype;
		String nsharecountry="%"+sharecountry+"%";
		String nshareregion="%"+shareregion+"%";
		String nsharecity="%"+sharecity+"%";
		String ntype= "".equals(type)?"%"+type+"%":type;
		String ncountry="%"+country+"%";
		String nregion="%"+region+"%";
		String ncity="%"+city+"%";
		sharePage = userIpInfoService.queryShareIp(shareNo, pageSize, state, u.getId(),nsharetype, nsharecountry, nshareregion, nsharecity);
		onlyPage = userIpInfoService.queryOnlyIp(onlyNo, pageSize, state, u.getId(), ntype, ncountry, nregion, ncity);
		shareCountries = otherService.queryCountry();
		shareTypes = otherService.queryTypes();
		countries = otherService.onlyCountry();
		types = otherService.onlyTypes();
		return "success";
	}
	
	public void setUserIpInfoService(UserIpInfoService userIpInfoService) {
		this.userIpInfoService = userIpInfoService;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public int getShareNo() {
		return shareNo;
	}

	public void setShareNo(int shareNo) {
		this.shareNo = shareNo;
	}

	public int getOnlyNo() {
		return onlyNo;
	}

	public void setOnlyNo(int onlyNo) {
		this.onlyNo = onlyNo;
	}

	public Page getSharePage() {
		return sharePage;
	}

	public Page getOnlyPage() {
		return onlyPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getOnlySize() {
		return onlySize;
	}

	public List<String> getCountries() {
		return countries;
	}

	public void setCountries(List<String> countries) {
		this.countries = countries;
	}

	public List<String> getTypes() {
		return types;
	}

	public void setTypes(List<String> types) {
		this.types = types;
	}

	public void setOtherService(OtherService otherService) {
		this.otherService = otherService;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getSharetype() {
		return sharetype;
	}

	public void setSharetype(String sharetype) {
		this.sharetype = sharetype;
	}

	public String getSharecountry() {
		return sharecountry;
	}

	public void setSharecountry(String sharecountry) {
		this.sharecountry = sharecountry;
	}

	public String getShareregion() {
		return shareregion;
	}

	public void setShareregion(String shareregion) {
		this.shareregion = shareregion;
	}

	public String getSharecity() {
		return sharecity;
	}

	public void setSharecity(String sharecity) {
		this.sharecity = sharecity;
	}

	public List<String> getShareCountries() {
		return shareCountries;
	}

	public List<String> getShareTypes() {
		return shareTypes;
	}
	
	
	private Integer id;
	/**
	 * 
	 * Description: <br>获取ip详细信息的时候弹出
	 * @return 
	 */
	public String usrip(){
		try {
			map = userIpInfoService.findMsg(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "success";
	}

	public Map<String, Object> getMap() {
		return map;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	
	
	
	
}
